﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using BLL.Action;

namespace Server
{
    //拍卖会选择页面
    public partial class SelectAuction : Window
    {
        public SelectAuction()
        {
            //构建窗体事件
            InitializeComponent();
            //显示今日拍卖会
            auction auction = new auction();
            auctionLV.DataContext = auction.getTodayAuctionLst();
            //既没指定Source又没指定Path的Binding  
            auctionLV.SetBinding(ListView.ItemsSourceProperty, new Binding());
            
            //窗体居中
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
        }

        /// <summary>
        /// 窗体拖拉操作
        /// </summary>
        private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left) this.DragMove();
        }

        /// <summary>
        /// 拍卖会列表双击事件,获取全局拍卖会编号
        /// </summary>
        private void auctionLV_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataRowView dataRow = (DataRowView)this.auctionLV.SelectedItem;
            App.currentAuctionNo = dataRow.Row["AUCTION_NO"].ToString();
            this.Hide();
            //显示主窗体
            MainWindow mainWin = new MainWindow();
            mainWin.Show();

            //关闭本窗体
            this.Close();
        }

        // 关闭窗体
        private void closeBtn_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        // 窗体关闭操作
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}
